// pages/points/index.ts
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tabs: [{
      id: 0,
      value: "四级",
      isActive: true
    }, {
      id: 1,
      value: "六级",
      isActive: false
    }, {
      id: 2,
      value: "考研",
      isActive: false
    }, {
      id: 3,
      value: "我的返现",
      isActive: false
    }],
    listData: [
      {
        title: '全国计算机二级真题解析',
        playDate: '08月01日',
        avatarList: [
          {
            "avatar": "/images/communication/teacher_01.png",
            "name": "serene"
          },
          {
            "avatar": "/images/communication/teacher_02.png",
            "name": "Anna"
          }
        ],
        name: 'Serene',
        price: 28.99,
        buyNum: 68,
      },
      {
        title: '英语四级真享受包 | 真题教辅',
        playDate: '10月25日',
        avatarList: [
          {
            "avatar": "/images/communication/teacher_03.png",
            "name": "mike"
          }
        ],
        name: 'Serene',
        price: 19.99,
        buyNum: 17,
      },
      {
        title: '英语四级过级冲刺班',
        playDate: '11月09日',
        avatarList: [
          {
            "avatar": "/images/communication/teacher_01.png",
            "name": "serene"
          },
          {
            "avatar": "/images/communication/teacher_02.png",
            "name": "Anna"
          },
          {
            "avatar": "/images/communication/teacher_03.png",
            "name": "mike"
          }
        ],
        name: 'Serene',
        price: 28.88,
        buyNum: 15,
      },
      {
        title: '(22年) 英语四级考前提分刷题班',
        playDate: '10月25日',
        avatarList: [
          {
            "avatar": "/images/communication/teacher_01.png",
            "name": "serene"
          },
          {
            "avatar": "/images/communication/teacher_02.png",
            "name": "Anna"
          },
          {
            "avatar": "/images/communication/teacher_03.png",
            "name": "mike"
          }
        ],
        name: 'Serene',
        price: 88.88,
        buyNum: 58,
      },

    ]
  },

  methods: {

  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
      this.getTabBar().setData({
        select: 2
      })
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },

  // 根据标题索引来激活选中 标题数组
  // handleTabsItemChange(index) {
  //   // 2 修改源数组
  //   let { tabs } = this.data;
  //   tabs.forEach((v, i) => i === index ? v.isActive = true : v.isActive = false);
  //   // 3 赋值到data中
  //   this.setData({
  //     tabs
  //   })
  // },
  // changeTitleByIndex(e) {
  //   // 1 获取被点击的标题索引
  //   const { index } = e.detail;
  //   this.handleTabsItemChange(index);
  //   // 2 重新发送请求 type=1 index=0
  //   // this.getOrders(index+1);
  // }
  handleTabsItemChange(e) {
    const { index } = e.detail;
    let { tabs } = this.data;
    console.log(tabs);
    tabs.forEach((v, i) => i === index ? v.isActive = true : v.isActive = false);
    this.setData({
      tabs
    })
  }
})